﻿using InfraTools.Class;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;


namespace InfraTools.Forms
{
    public partial class frmNewComputer : Form
    {



        public string itemtype { get; set; }
        public string Hostname { get; set; }
        public string Serial { get; set; }
        public string PN { get; set; }
        public string uuid { get; set; }
        public string type { get; set; }
        public BarCode BC { get; set; }
                   
        public Computers temppc = new Computers();

        public frmNewComputer()
        {
            InitializeComponent();
                       
        }

        private void New_Computer_dialog_Load(object sender, EventArgs e)
        {
          
            if (BC.type == "modelserial")
            {

                temppc.name = Hostname;
                temppc.serial = BC.Serial;
                lblhostnameval.Text = Hostname;
                lblSerial.Text = Serial;
                type = BC.type;
                LblSerialVal.ForeColor = Color.Green;
                lblhostnameval.ForeColor = Color.Green;
                lblUuidVal.ForeColor = Color.Red;
                txtscan.SelectAll();
                txtscan.Focus();
                
                Show();



            }
            else if (BC.type == "uuid")
            {
                temppc.name = Hostname;
                temppc.uuid = BC.uuid;
                LblSerialVal.ForeColor = Color.Red;
                lblhostnameval.ForeColor = Color.Red;
                lblUuidVal.Text = "UUID";
                lblUuidVal.ForeColor = Color.Green;
                txtscan.SelectAll();
                txtscan.Focus();


                

            }
        }






        private void txtscan_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Enter)
            {
                if (BC.type == "modelserial")
                {
                    BC.getbarcode(txtscan.Text);
                    temppc.uuid = BC.uuid;
                    Hide();

                }

                else if (BC.type == "uuid")
                {
                    BC.getbarcode(txtscan.Text);
                    temppc.serial = BC.Serial;
                    Hide();
                }


            }
        }
    }
}
